package com.heima.admin.controller.v1;

import com.heima.apis.wemedia.IWemediaClient;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.ChannelDto;
import com.heima.model.wemedia.pojos.WmChannel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/channel")
public class AdminChannelController {
    @Autowired
    private IWemediaClient iWemediaClient;
    /**
     * 修改频道
     *
     * @param wmChannel
     * @return
     */
    @PostMapping("/update")
    public ResponseResult updateChannels(@RequestBody WmChannel wmChannel) {
        return iWemediaClient.updateChannels(wmChannel);
    }
    /**
     * 保存频道
     *
     * @param
     * @return
     */
    @PostMapping("/save")
    public ResponseResult saveChannels(@RequestBody WmChannel wmChannel) {
        System.out.println(wmChannel.toString());
        return iWemediaClient.saveChannels(wmChannel);
    }

    /**
     * 频道名称模糊分页查询
     *
     * @param dto
     * @return
     */
    @PostMapping("/list")
    public ResponseResult checkListChannels(@RequestBody ChannelDto dto) {
        return iWemediaClient.checkListChannels(dto);
    }

    /**
     * 平台管理-删除频道
     *
     * @param id
     * @return
     */
    @GetMapping("/del/{id}")
    public ResponseResult delChannels(@PathVariable("id") Integer id) {
        return iWemediaClient.delChannels(id);

    }
}
